I’ve tried updating my PHP to 7.2 or up on my local Apache server. It did not work at first. I would pause this if I did not work on a project that required the newer PHP Unit. The newer one requires PHP 7.2 or up. These is a short tutorial that will show you how I successfully updated my PHP to 7.2.9.

If you’re reading this, you’ve probably tried updating your PHP from
https://php-osx.liip.ch/.

I’ve waited a bit on it since I heard there were some issues. When I updated my macOS to Mojave 10.14, I could not start my PHP apps. I had to go to my local apache configuration etc/apache2/httpd.conf and do these:

#LoadModule php5_module /usr/local/php5/libphp5.so
LoadModule php7_module libexec/apache2/libphp7.so

What this did is to unload the older php5_module (which might be a PHP 7.1 or so since the above https://php-osx.liip.ch/ installs every module on that path). And it has also loaded the default PHP 7.1 that came with Mojave.

That worked fine. But now that I’ve needed a newer PHP version, I could not move.

Updating to PHP 7.2.9

I’ve tried the terminal command recommended by PHP-OSX:

curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2

Then, they’ve informed me that there are issues and linked this https://github.com/liip/php-osx/issues/249. If I am certain I want to install it, I had to do this:

curl -s https://php-osx.liip.ch/install.sh | bash -s force 7.2

After waiting a few more days, I’ve updated my Mojave to 10.14.4 as others noted that it worked for them. It did not for me.

Since loading the php5_module did nothing for me (actually messed everything up), I did not want to do that anymore. So, I figured, if they update that module through the terminal, maybe I could link directly to the downloaded PHP version.

If you have ran the above command, try typing (in the terminal) ls /usr/local/php and press TAB to list all the available PHP modules that are downloaded. If you did this before, you might have a few modules.

The latest, PHP 7.2.9 was there also at /usr/local/php5-7.2.9-20180821-074958. So, I opened the Apache config by typing sudo nano /etc/apache2/httpd.conf.

Then I found the modules and changed it to this:

#LoadModule php5_module /usr/local/php5/libphp5.so
#LoadModule php7_module libexec/apache2/libphp7.so
LoadModule php7_module /usr/local/php5-7.2.9-20180821-074958/libphp7.so

After that, I had to restart the Apache with sudo apachectl restart.

And now I had the PHP 7.2.9 installed and ran by my local Apache server.

Conclusion

You can always be sure that you’ll be able to load the PHP modules by directly loading them. If you’re modules were downloaded in the temporary folder on your system, be sure to move them elsewhere, otherwise those modules will be removed after shutdown.

Become a Sponsor

Posted by Igor Benic

Web Developer who mainly uses WordPress for projects. Working on various project through Codeable & Toptal. Author of several ebooks at https://leanpub.com/u/igorbenic.

2 Comments

  1. Thanks a lot for your detailed instructions!
    I’m going to switch to Mojave soon and since I’d like to continue working with the PHP build by php-osx.liip.ch, this is going to be very helpful. 🙂
    Great work!

    Reply

  2. Thanks Igor, everything is working fine with PHP Version 7.3.6 and Mojave 10.14.5. How can I change my shell PHP version too? Because now my localhost is using 7.3 and my shell is using 7.1.

    Reply

Leave a reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.